<%--
  Created by IntelliJ IDEA.
  Date: 2022/5/13
  Time: 11:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" +request.getServerPort() +
            request.getContextPath() + "/";
%>
<html>
<head>
    <base href="<%=basePath%>">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/bootstrap.min.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <title>Title</title>
</head>
<body>
<input id="PageContext" type="hidden" value="${pageContext.request.contextPath}" />
<!-- 内容主体区域 -->
<nav class="navbar navbar-light">
    <a class="navbar-brand"></a>
</nav>
<ul class="layui-nav layui-nav-tree">
</ul>
<div style="padding: 15px;">
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
            <h1></h1>
            <tr>
                <td>宠物</td>
                <td>描述</td>
                <td>诊断时间</td>
            </tr>
            </thead>
            <tbody id="information">

            </tbody>
        </table>
    </div>
</div>
</body>
<script>
    $(function () {
        LoadVistsData();
    })
    //ajax请求
    function LoadVistsData() {
        $.ajax({
            url: $("#PageContext").val()+"/getVisit",
            type: "get",
            dataType: "json",
            success: function (data) {
                console.log(data)
                //清除旧的数据
                $("#information").html("");
                //添加新的数据
                $.each(data, function (i, n) {
                    $("#information").append("<tr>")
                        .append("<td>" + n.pet.name + "</td>")
                        .append("<td>" + n.description+ "</td>")
                        .append("<td>" + n.visitDate + "</td>")
                        .append("</tr>")
                });
            },
        })
    }

</script>
</html>
